package com.catena.web;

import com.catena.core.CatenaControllerBase;
import com.catena.mock.MockRuntimeException;
import com.catena.mock.core.ScanProjectContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by hx-pc on 16-11-21.
 */
@ControllerAdvice
public class MockExceptionHandler extends CatenaControllerBase{

    @Autowired
    private ScanProjectContext scanProjectContext;

    private static final Logger LOGGER = LoggerFactory.getLogger(MockExceptionHandler.class);

    @ExceptionHandler(value = MockRuntimeException.class)
    public void handleMockRuntimeException(HttpServletRequest servletRequest, HttpServletResponse servletResponse, MockRuntimeException e) {
        getOperation("returnData").startForward(e.toMap(), servletRequest, servletResponse, "error");
    }

}
